package book;

public class BookList {

    private Book[] books = new Book[10];
    private int usedSize; //存储当前书的个数

    /**
     * 事先通过构造方法，初始化的时候，给数组里边预存3本书，usedSize = 3;
     */
    public BookList(){
        books[0] = new Book("三国演义","罗贯中",89,"小说");
        books[1] = new Book("西游记","吴承恩",78,"小说");
        books[2] = new Book("红楼梦","曹雪芹",49,"小说");
        this.usedSize = 3;  //谁调用了BookList，谁就是this
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }

    //方法返回的类型是--Book 也就是返回的是books[pos]位置上的书的信息
    public Book getPos(int pos){
        return books[pos];
    }

    /**
     * 存储一本书
     * @param book 要存储的书籍
     * @param pos  存储到指定的位置
     */
    public void setBooks(Book book,int pos) {
        books[pos] = book;
    }
}
